﻿import os

with open('README.md', mode='w', encoding='UTF-8') as f:
    line = '# ReadingNote\n\n#### 介绍\n记录阅读中的笔记。\n'
    f.write(line)
    for root, dirs, files in os.walk('./文档'):
        md_ditc = {}
        for file in files:
            if file.find('.md') != -1:
                key = file.split('.md')[0]
                key = key.replace(' ', '%20')
                md_ditc[key] = key
        for file in files:
            if file.find('.md') == -1:
                filename = file.replace(' ', '%20')
                for key in md_ditc:
                    if filename.find(key) != -1:
                        line = '\n#### '
                        line += key.replace('%20', ' ') + '\n'
                        line += '[{}](./文档/{}.md)\n'.format('阅读笔记', key)
                        line += '\n[{}](./文档/{})\n'.format('原文', filename)
                        f.write(line)
os.system('g.sh')
